Convert array to machine values

AB = AI.tobytes() AI2.frombytes(AB)

Read a string and interpreting the string as an array of machine values.
Expected output:
array1: array(‘i’, [7, 8, 9, 10])
Bytes: b’0700000008000000090000000a000000’
array2: array(‘i’, [7, 8, 9, 10])
from array import array
import binascii

AI = array('i', [7, 8, 9, 10])
print('array1: ', AI)

AB = AI.tobytes()
print('Bytes: ', binascii.hexlify(AB))

AI2 = array('i')
AI2.frombytes(AB)
print('array2: ', AI2)

Output:

array1: array('i', [7, 8, 9, 10])
Bytes: b'0700000008000000090000000a000000'
array2: array('i', [7, 8, 9, 10])